import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);

let baseRoute = [
 {
  path: '/',
  name: 'home',
  component: (resolve) => require(['../views/index.vue'], resolve)
}, 
{
  path: '/login',
  name: '登录',
  component: (resolve) => require(['../views/login.vue'], resolve)
},{
  path: '/register',
  name: '注册',
  component: (resolve) => require(['../views/register.vue'], resolve)
},{
  path: '/transaction',
  name: '交易中心',
  component: (resolve) => require(['../views/transaction.vue'], resolve)
},{
  path: '/assetmanage',
  name: '资产管理',
  // component: (resolve) => require(['../views/index.vue'], resolve),

  children:[
    {
      path:'accountassets',
      name:'账户资产',
      component: (resolve) => require(['../views/accountassets.vue'], resolve),
      
    },
    {
      path:'btcxexcharge',
      name:'BTCX兑换',
      component: (resolve) => require(['../views/btcxexcharge.vue'], resolve),

    },
    {
      path:'ccdeal',
      name:'C2C交易',
      component: (resolve) => require(['../views/ccdeal.vue'], resolve),

    },
    {
      paht:'withdrawalsmanage',
      name:'提现地址管理',
      component: (resolve) => require(['../views/withdrawalsmanage.vue'], resolve),

    }
  ]
},{
  path: '/order',
  name: '订单',
  // component: (resolve) => require(['../views/index.vue'], resolve),  
  children:[
    {
      path:'entrustrecord',
      name:'委托记录',
      component: (resolve) => require(['../views/entrustrecord.vue'], resolve),
      
    },
    {
      path:'dealrecord',
      name:'成交记录',
      component: (resolve) => require(['../views/dealrecord.vue'], resolve),
      
    },
    {
      path:'rechargerecord',
      name:'充值记录',
      component: (resolve) => require(['../views/rechargerecord.vue'], resolve),
      
    },
    {
      paht:'withdrawalsrecord',
      name:'提现记录',
      component: (resolve) => require(['../views/withdrawalsrecord.vue'], resolve),
      
    }
  ]
},{
  path: '/personalcenter',
  name: '个人中心',
  component: (resolve) => require(['../views/personalcenter.vue'], resolve)
},{
  path: '/newhelp',
  name: '新手帮助',
  component: (resolve) => require(['../views/newhelp.vue'], resolve)
}, {
  path: '/401',
  name: '无权访问',
  component: (resolve) => require(['../views/common/401.vue'], resolve)
}, {
  path: '/404',
  name: '找不到页面',
  component: (resolve) => require(['../views/common/404.vue'], resolve)
}];

let router = new Router({
  routes: baseRoute
});

router.beforeEach((to, from, next) => {
  let routeName = to.meta.name || to.name;
  window.document.title = (routeName ? routeName + ' - ' : '') + '交易平台';
  next();
});

export default router;
